/**
 * Created by WUJO5 on 3/26/2018.
 */
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)

const state = {
  logined:false,
  loginUser: {
    userName:'',
  }
};

const mutations = {
  LOGIN(state) {
    state.logined = true;
    let user = JSON.parse(sessionStorage.getItem('user'));
    console.log('user: ',user);
    state.loginUser.userName = user;
  },
  LOGOUT (state) {
    state.logined = false;
    state.loginUser.userName = '';
  }
};

const actions = {
  login(context) {
    context.commit('LOGIN')
  },
  logout(context) {
    context.commit('LOGOUT')
  }
}

export default new Vuex.Store({
  state,
  mutations,
  actions
})

